package indigo.shiro.config;

import static indigo.shiro.config.ShiroFilterRegistrar.DEFAULT_LOGIN_URL;
import static indigo.shiro.config.ShiroFilterRegistrar.DEFAULT_SECURITY_MANAGER_BEAN_NAME;
import static indigo.shiro.config.ShiroFilterRegistrar.DEFAULT_SUCCESS_URL;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor;

@Documented
@Retention(RUNTIME)
@Target(TYPE)
@Import({ ShiroConfiguration.class, ShiroFilterRegistrar.class })
public @interface EnableShiroFilter {
	@AliasFor("filterChains")
	FilterChain[] value() default {};

	String loginUrl() default DEFAULT_LOGIN_URL;

	String successUrl() default DEFAULT_SUCCESS_URL;

	String unauthorizedUrl() default "";

	String securityManagerRef() default DEFAULT_SECURITY_MANAGER_BEAN_NAME;

	Filter[] filters() default {};

	@AliasFor("value")
	FilterChain[] filterChains() default {};

	@Retention(RUNTIME)
	@Target({})
	public @interface Filter {
		String name();

		Class<? extends Filter> type();
	}

	@Retention(RUNTIME)
	@Target({})
	public @interface FilterChain {
		String name();

		String definition();
	}
}
